package bmatch.tech.hello.dao.buider;

import org.apache.ibatis.jdbc.SQL;

/**
 * CitySqlBuilder的注释
 *
 * @author: Awake
 * @date: 2018-12-05 16:57
 **/
public class CitySqlBuilder {
    public String buildQueryCitys(String name, String code) {
        return new SQL() {{
            SELECT(
                    "id,code,name,level,parent_code as parentCode,gmt_created as gmtCreated,gmt_modified as gmtModified");
            FROM("common_city_code");
            if (code != null) {
                WHERE("code = #{code}");
            } else if (name != null) {
                WHERE("name like CONCAT(#{name} , '%')");
            }
            ORDER_BY("id");
        }}.toString();
    }
}
